package com.hpc.Controller;

import Utils.JSONUtil;
import com.alibaba.fastjson.JSON;
import entity.user;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/ts/user/rpc")
public class RPCController {
    @Resource
    private com.hpc.Service.userService userService;
    @GetMapping("/getUserInfoByArticleId")
    public String getUserInfoByArticleId(String articleId){
        user userInfoByArticleId = userService.getUserInfoByArticleId(articleId);
        return JSONUtil.toJSONString(userInfoByArticleId);
    }
    @GetMapping("/getUserInfoOfComment")
    public String getUserInfoOfComment(@RequestParam("userIds") String userIdsJson){
        ArrayList userIds = JSON.parseObject(userIdsJson, ArrayList.class);
        List<user> userInfoOfComment = new ArrayList<user>();
        if (userIds.size()==0){
            return JSONUtil.toJSONString(userInfoOfComment);
        }else {
            userInfoOfComment=userService.getUserInfoOfComment(userIds);
            return JSONUtil.toJSONString(userInfoOfComment);
        }
    }
}
